﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using HR_Interfaces;
namespace ClientApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        IEmployeeRemotingObject h = null;
        private void button1_Click(object sender, EventArgs e)
        {
            try{
            //connect 
            TcpChannel channel = new TcpChannel();
            string url = "tcp://" + txt_IP.Text + ":" + txt_Port.Text + "/EmployeeRemotingObject";
            h = (IEmployeeRemotingObject)Activator.GetObject(typeof(IEmployeeRemotingObject), url);
            MessageBox.Show("Connect");
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {

                Gripview_Emp.DataSource = h.GetAllEmployees();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void Gripview_Emp_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        } 
    }
}
